﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using DLV.Utilities;

namespace DLV.Data.Entities
{
    public class RoomController
    {
        public int InsertRoom(RoomInfo info)
        {
            return SQL.InsertRoom(info.HotelId, info.RoomTypeId, info.Utilities, info.RoomName, info.SortDescription, info.DetailDescription, info.RoomQuantity, info.PersonQuantity, info.Acreage, info.CreatedBy, info.CreatedDate, info.UpdatedBy, info.UpdatedDate, info.Status);
        }
        public void UpdateRoom(RoomInfo info)
        {
            SQL.UpdateRoom(info.RoomId, info.HotelId, info.RoomTypeId, info.Utilities, info.RoomName, info.SortDescription, info.DetailDescription, info.RoomQuantity, info.PersonQuantity, info.Acreage, info.CreatedBy, info.CreatedDate, info.UpdatedBy, info.UpdatedDate, info.Status);
        }
        public void DeleteRoom(RoomInfo info)
        {
            DeleteRoom(info.RoomId);
        }
        public void DeleteRoom(int roomId)
        {
            SQL.DeleteRoom(roomId);
        }
        public RoomInfo GetRoom(int roomId)
        {
            return CBO.FillObject<RoomInfo>(SQL.GetRoom(roomId));
        }
        public List<RoomInfo> ListRoom()
        {
            return CBO.FillCollection<RoomInfo>(SQL.ListRoom());
        }
        public DataTable SelectRoom()
        {
            return CBO.ConvertToDataTable(ListRoom(), typeof(RoomInfo));
        }

       
        public List<RoomInfo> ListRoomByHotel(int hotelId)
        {
            return ListRoom().Where(p => p.HotelId == hotelId).ToList();
            //return CBO.FillCollection<RoomInfo>(SQL.ListRoomByHotel(hotelId));
        }
        public List<RoomInfo> ListRoomByHotelAndType(int hotelId)
        {
            return CBO.FillCollection<RoomInfo>(SQL.ListRoomByHotelAndType(hotelId));
        }
        public Dictionary<object, object> ListRoomLookup()
        {
            var users = ListRoom();
            var dicusers = new Dictionary<object, object>();
           
            foreach (RoomInfo info in users)
            {
                    dicusers.Add(info.RoomId, info.RoomName);
                
            }
            return dicusers;
        }
    }
}
